package com.million.eduservice.controller;


import com.million.commonutils.R;
import com.million.eduservice.entity.vo.subject.SubjectNestedVo;
import com.million.eduservice.service.EduSubjectService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * <p>
 * 课程科目 前端控制器
 * </p>
 *
 * @author 十麓
 * @since 2022-03-23
 */
@Api(tags = "课程分类管理")
@RestController
@RequestMapping("/eduservice/edu-subject")
public class EduSubjectController {

    @Autowired
    private EduSubjectService eduSubjectService;

    //添加课程分类
    //获取上传过来文件，把文件内容读取出来
    @PostMapping("addSubject")
    public R addSubject(MultipartFile file){
        //上传过来excel文件
        eduSubjectService.saveSubject(file);
        return R.ok();
    }

    //查询课堂列表
    @GetMapping("getAllSubject")
    public R getAllSubject(){
        List<SubjectNestedVo> subjectsList = eduSubjectService.getAllSubject();
        return R.ok().data("items",subjectsList);
    }
}

